package component.fulltextsearch.entity;

import javax.servlet.http.HttpServletRequest;

import component.fulltextsearch.util.ClassLoaderUtil;
import component.fulltextsearch.util.SearchConfigUtil;

/**
 * 用户信息代理类
 *
 */
public class UserInfoProxy implements IUserInfo {
	private static IUserInfo instance = null;
	private IUserInfo userInfo = null;
	private UserInfoProxy() {
		String className =SearchConfigUtil.getInstance().getProperty("userinfo");
		try {
			Class clazz = ClassLoaderUtil.loadClass(className, this.getClass());
			userInfo = (IUserInfo) clazz.newInstance();
		} catch (Exception e) {		
			e.printStackTrace();
		}
	}
	
	public String getCurUserId(HttpServletRequest request) {		
		return userInfo.getCurUserId(request);
	}

	public String[] getCurUserRoles(HttpServletRequest request) {	
		return userInfo.getCurUserRoles(request);
	}
	public static IUserInfo getUserInfo() {
		if (instance == null) {	
			instance = new UserInfoProxy();
		}
		return instance;
	}
}
